/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hybris;

import java.awt.AlphaComposite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 *
 * @author Jeppe
 */
public class SpaceShip {

    private int health;
    private int x, y;
    private int speed;
    private BufferedImage img;

    public SpaceShip() {
        health = 100;
        x = 0;
        y = 0;
        speed = 0;
        try {
            img = ImageIO.read(new File("SpaceShip1.png"));
        } catch (IOException e) {
            System.out.println("Could not load image: " + e.getMessage());
        }
    }

    public void draw(Graphics g, int SW, int SH) {
        int SW2 = SW / 2;
        int SH2 = SH / 2;
        int imgWidth = img.getWidth();
        int imgHeight = img.getHeight();
        int imgX = SW2 - (imgWidth / 2);
        int imgY = SH2 - (imgHeight / 2);

        Graphics2D g2d = (Graphics2D) g;
        g2d.getComposite();
        AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
        g2d.setComposite(alphaComposite);
        g2d.drawImage(img, imgX, imgY, null);
        g2d.dispose();
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }

    public BufferedImage getImg() {
        return img;
    }

    public void setImg(BufferedImage img) {
        this.img = img;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

}
